<template>
	<div id="app">
		<router-view />
		<van-tabbar route v-if="$route.meta.showFooter">
			<van-tabbar-item replace to="/home" icon="home-o">首页</van-tabbar-item>
			<van-tabbar-item replace to="/fenlei" icon="fire-o">分类</van-tabbar-item>
			<van-tabbar-item replace to="/cart" icon="shopping-cart-o"
				>购物车</van-tabbar-item
			>
			<van-tabbar-item replace to="/mine" icon="manager-o"
				>我的</van-tabbar-item
			>
		</van-tabbar>
	</div>
</template>

<script>
export default {
	name: "App",
	components: {},
	created() {
		// token在vuex中的持久化处理。获取token，使用mutations的commit更改
		const token = localStorage.getItem("token") || "";
		this.$store.commit("token/changeToken", token);
		// 将地址在本地存储存获取。进行vuex持久化处理
		const addressInfo = JSON.parse(localStorage.getItem("addressInfo"));
		console.log(addressInfo);
		this.$store.commit("address/changereceiver", addressInfo.receiver);
		this.$store.commit("address/changeregions", addressInfo.regions);
		this.$store.commit("address/changeaddress", addressInfo.address);
	},
};
</script>

<style></style>
